/******************************************
 *Author:庄育龙
 *Function:主窗口各部件功能实现，包括按钮、菜单及其事件等
 *Created Date:2013.05.02
 *Last Modified:2013.05.28
 ******************************************/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QString>
#include <QTextStream>
#include <QtNetwork>
#include <QUdpSocket>

enum MessageType1{NewPoint,Undo,Left,refuse,allow,Restart,allowrestart,refuserestart};
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
protected:
    void sendMessage(MessageType1 type, int x, int y);
    
private slots:
    void on_action_4_triggered();

    void on_action_3_triggered();

    void on_pushButton_3_released();

    void ChangeColor(bool Inturn);

    void on_pushButton_2_clicked();

    void on_pushButton_clicked();

    void AddItem(int x,int y,int who);

    void WinNotify(int who,bool isban);

    void NewGame(QString userID,QString myIP,QString yourIP,bool iFirst,bool EnableForbidden,bool AllowUndo);

    void on_action_2_triggered();

    void on_action_triggered();

    void processPendingDatagrams();

    void newpoint(int,int);

    void on_pushButton_4_clicked();

private:
    Ui::MainWindow *ui;
    QUdpSocket *udpSocket;
    QString getIP();
signals:
    void send(bool);
    void additem(int,int,int);
    void win(int,bool);
};

#endif // MAINWINDOW_H
